<template>
	<view class="page-index">
		<view class="search">
			<u-search placeholder="请输入查询关键字" v-model="queryInfo" :showAction='true' @custom='search()' @search="search" :animation='true'></u-search>
		</view>
		<!-- 筛选条件 -->
		<Select />
		<!-- 租房列表 -->
		<HomeList :homeList='homeList' />
		<u-loadmore :status="status" />
	</view>
</template>

<script>
	import * as index from '@/api/index.js'
	import Select from '@/components/select/select.vue'
	import HomeList from '@/components/homeList/homeList.vue'
	export default {
		components: {
			Select,
			HomeList
		},
		data() {
			return {
				queryInfo: '', //搜索框内容
				homeList: [], //列表1
				form: {
					page: 1,
					areas_id: 0,
					configure_id: [0],
					size_id: [0],
					page: 1,
					rent_id: 0,
					tentype_id: 0,
					type: 2
				},
				status: 'nomore'
			}
		},
		onLoad(params) {
			this.title = uni.getStorageSync('types')
			uni.setNavigationBarTitle({
				title: this.title.title
			});
			// this.form.tentype_id = params.id
			let that = this
			uni.$on('formSearch', function(data) {
				console.log('formSearch');
				that.homeList = []
				that.form = data
				that.getList()
			})
			// this.getList()
		},
		onReachBottom() {
			this.form.page += 1
			this.getList()
		},
		methods: {
			getList() {
				let form = this.form
				var objString = JSON.stringify(form);
				var obj2 = JSON.parse(objString);
				obj2.title = this.queryInfo
				obj2.configure_id = obj2.configure_id.join()
				obj2.size_id = obj2.size_id.join()
				obj2.type = 2
				this.status = 'loading'
				index.getList(obj2).then(res => {
					// console.log(obj2);
					this.homeList.push(...res.data.data)
					this.status = 'nomore'
				})
			},
			search() {
				this.homeList = []
				this.getList()
			},
			firm() {
				console.log(66666666666);
			}
		}
	}
</script>

<style scoped lang="scss">
	.page-index {
		padding: 32rpx;
	}
</style>
